﻿using System;
using System.Reflection;
using Wireframe;

namespace SampleWebCrawler
{
    internal class Program
    {
        private static void Main()
        {
            // Run "Initialize" method in order to search assemblies for types with callbacks.
            // Event handler callback method name must start with "Handle" and end with "Event", and also
            // event handler callback must have a single parameter in order to be recognized as a callback.
            Wire.Initialize(Assembly.GetExecutingAssembly());

            // "Register" is an extension method, that returns registered instance of an event handler.
            // In this case the following classes are all event handlers.
            HtmlLoader htmlLoader = new HtmlLoader().Register();
            HtmlParser htmlParser = new HtmlParser().Register();
            UriLogger uriLogger = new UriLogger().Register();
            UriDatabase uriDatabase = new UriDatabase().Register();
            ExceptionLogger exceptionLogger = new ExceptionLogger().Register();

            // "Wire" is an entry point to send events (or extension method for non-static contexts).
            // Specify the type of event and the event data.
            // When event is sent callback method will be invoked.
            // Event handler callbacks are run inside of a thread pool.
            Wire.Send(new LoadHtmlEvent(@"http://en.wikipedia.org/wiki/Main_Page"));

            Console.ReadLine();
        }
    }
}